import 'package:flutter/material.dart';
import 'package:flutter_magic_planet/component/cached_image.dart';
import 'package:get/get.dart';

import 'logic.dart';

class ComicPlayerPage extends StatelessWidget {
  final ComicPlayerLogic logic = Get.put(ComicPlayerLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Obx(() {
        return Container(
          child: logic.comic.value.content == null
              ? Center(
                  child: Text('暂无数据'),
                )
              : ListView.builder(
                  itemBuilder: (context, index) {
                    String url = logic.comic.value.content![index] ?? '';
                    url = url.trim();
                    return CachedImage(
                      imageUrl: url,
                      fit: BoxFit.fitWidth,
                      width: Get.width,
                    );
                  },
                  itemCount: logic.comic.value.content == null
                      ? 0
                      : logic.comic.value.content!.length,
                ),
        );
      }),
    );
  }
}
